//
//  ASInventorBankingVC.m
//  AttendenceSys
//  发明人排名
//  Created by 窦芳俊 on 16/5/17.
//  Copyright © 2016年 窦芳俊. All rights reserved.
//

#import "ASInventorBankingVC.h"

#define kInventorBankingCellHeight 50

@interface ASInventorBankingVC () <UITableViewDataSource, UITableViewDelegate>

@property (nonatomic, strong) UITableView  *tableView;
@property (nonatomic, strong) NSArray      *infoArray;

@end

@implementation ASInventorBankingVC

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    _infoArray = @[@"第一发明人", @"第二发明人"];
    
    self.strNavTitle = @"发明人排名";
    self.view.backgroundColor = [UIColor whiteColor];
    
    _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
    _tableView.frame = CGRectMake(0, 0, self.view.frame.size.width, [_infoArray count] * kInventorBankingCellHeight);
    _tableView.delegate = self;
    _tableView.dataSource = self;
    _tableView.backgroundColor = [UIColor whiteColor];
    _tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
    _tableView.rowHeight = kInventorBankingCellHeight;
    [self.view addSubview:_tableView];
    
    [_tableView reloadData];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
}

#pragma mark - UITableViewDataSource

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [_infoArray count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:@"inventorBankingTableViewCellIdentifier"];
    if (cell == nil)
    {
        cell = [[UITableViewCell alloc] init];
    }
    
    cell.textLabel.text = [_infoArray objectAtIndex:[indexPath row]];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    
    return cell;
}

#pragma mark - UITableViewDelegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    if (self.delegate && [self.delegate respondsToSelector:@selector(selectInventorBanking:)])
    {
        [self.delegate selectInventorBanking:[_infoArray objectAtIndex:[indexPath row]]];
    }
}



@end
